class OfferController < ApplicationController
  

  def new
    @user = User.find(session[:user])
    @for_book = Book.find(params[:id])
    @my_books = Book.getMyBooks(session[:user])
  end

  def create
    @offer = Offer.new(:for_book_id => params[:for_book_id], :offer_book_id => params[:offer][:offer_book_id], :status => 1)
    if @offer.save
      flash[:notice] = 'Your offer is recorded'
      redirect_to :controller=> "user", :action => "offers"
    else
      flash[:notice] = 'Big Fat Error :for_book_id => ' + params[:for_book_id] + ' :offer_book_id => ' + params[:offer][:offer_book_id] + ' :status => 1'
      redirect_to :controller => "book",  :action => "index"
    end
  end
  
  #TO DO
  #write an action to accept some ones offer, and reject all others.  It must redact all offers pending on the book.
end